import serial


DF_HEAD = b'\xff'


port = input("input serial port: ")

with serial.Serial(port) as ser:
    ser.baudrate = 115200
    ser.timeout = 0.5

    while True:
        val = int(input("input: "))
        bytes = val.to_bytes(length=2, byteorder='little', signed=True)
        df = DF_HEAD + bytes  # data frame
        
        print('sent >', df)
        ser.write(df)
        print('recv >', ser.read(10000))

